<!--大额延迟结算回执审核-->
<template>
  <div class="app-container">
    <ht-search-form
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :beforeSearchCallback="false"
      @beforeSearchCallback="beforeSearchCallback"
      :clearCallBack="clearCallBack"
    >
      <template slot="endSlotOption">
        <amount-range-search label="金额区间" ref="amountRangeSearch"></amount-range-search>
      </template>
    </ht-search-form>

    <ht-table
      ref="dataTable"
      rowKey="coreId"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    toViewDetail(scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <query-detail-dialog ref="editInfo" :dictMap="dictMap" :form="form"></query-detail-dialog>

  </div>
</template>
<script>
import { mapGetters } from "vuex";
import { apiUrlConfig4, detail117 } from "@/api/cnaps/baseBiz/send/check/creditCheck";
import { listPageMixin } from "@/libs/listPageMixin";
import AmountRangeSearch from "@/views/components/AmountSearchInput";
import QueryDetailDialog from "@/views/cnaps/baseBiz/send/check/hvps_delayed settlement/components/Details";

export default {
  name: "CreditCheck",
  mixins: [listPageMixin],
  components: {
    QueryDetailDialog,
    AmountRangeSearch,
  },
  data() {
    return {
      form: {},
      reqConfig: apiUrlConfig4,
      //数据字典
      searchFormDictList: [
        "PKG_TYPE",
        "BIZ_TYPE",
        "BIZ_CTGY",
        "TXN_SOURCE",
        "BIZRT_STATUS_117",







      ],
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: "",
        cpgdate1: "",
        cpgdate2: "",
        workdate: "",
        workdate2: "",
        amount1: "",
        amount2: "",
        source: "",
      },
      formOptions: [],
      tableBindColumns: [
        { prop: 'sysCode',  label: '系统编号', dictCode:"Cnaps2Dict.SYSTEMCODE" },
        { prop: 'coreId',  label: '交易流水号'},
        { prop: 'vdate',  label: 'CPG日期', type:"date"},
        { prop: 'workdate',  label: '工作日期', type:"date"},
        { prop: 'pkgno',  label: '原报文类型', dictCode: "PKG_TYPE"},
        { prop: 'bizTypeCode',  label: '原业务类型', dictCode: "BIZ_TYPE"},
        { prop: 'bizCtgyCode',  label: '原业务种类', dictCode: "BIZ_CTGY"},
        { prop: 'amount',  label: '交易金额', type:"price"},
        { prop: 'status',  label: '业务状态', dictCode:"Cnaps2Dict.CP2_STATUS" },
        { prop: 'source',  label: '来源', dictCode:"Cnaps2Dict.TXN_SOURCE" },
      ],
    };
  },
  computed: {
    ...mapGetters(["name", "globalBusData"]),
  },
  created() {
    this.queryParams.brno = this.globalBusData.brno;
  },
  mounted() {
    this.$refs.amountRangeSearch.$on('getAmountRange',this.beforeSearchCallback);

    this.formOptions = [
      {
        type: "input",
        prop: "id",
        defaultAttr: {
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "dict",
        prop: "source",
        dict: "Cnaps2Dict.TXN_SOURCE",
        defaultAttr: {
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgdate1",
          endTimeName: "cpgdate2",
        },
        defaultAttr: {
          label: "CPG日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate1",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          label: "工作日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
    ];
  },
  methods: {
    beforeSearchCallback() {
      // 搜索按钮之前先执行
      this.queryParams.amount1 = this.$refs.amountRangeSearch.getAmount1();
      this.queryParams.amount2 = this.$refs.amountRangeSearch.getAmount2();
    },
    clearCallBack() {
      let that = this;
      return new Promise(function (resolve, reject) {
        that.$refs.amountRangeSearch.clearAmount();
        that.queryParams.amount1 = "";
        that.queryParams.amount2 = "";
      });
    },
    editComplete(state) {
      console.log("editComplete", state);
      if (state == true) {
        this.getList();
      }
    },
    /** todo 查询当天操作员的交易记录 */
    getList() {
      this.doQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /*查看明细*/
    toViewDetail(row) {
      detail117({ coreId: row.coreId }).then((res) => {
        this.form = _.clone(res.result);
        this.$refs.editInfo.show();
      });
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
